import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)


// 静态引入
// import login from '../pages/login/login.vue'
// 动态引入
let login =()=>import("../pages/login/login.vue")
let register =()=>import("../pages/register/register.vue")
let adress =()=>import("../pages/adress/adress.vue")
let cate =()=>import("../pages/cate/cate.vue")
let detail=()=>import("../pages/detail/detail.vue")
let list =()=>import("../pages/list/list.vue")
let mine =()=>import("../pages/mine/mian.vue")
let order =()=>import("../pages/order/order.vue")
let pay=()=>import("../pages/pay/pay.vue")
let shop=()=>import("../pages/shop/shop.vue")
let store=()=>import("../pages/store/store.vue")
let index=()=>import("../pages/index/index.vue")
let search=()=>import("../pages/search/search.vue")
let addr=()=>import("../pages/address.add/addr.vue")

// 懒加载注册路由
const routes = [
  // 路由规则
  {
    path:"/addr",
    component:addr,
    meta:{
      title:"添加地址",
      goBack:true
    }
  },
  {
    path:"/login",
    component:login,
    // 元信息
    meta:{
      title:"登录"
    }
  },
  {
    path:"/search",
    component:search,
    // 元信息
    meta:{
      title:"搜索"
    }
  },
  {
    path:"/register",
    component:register,
    // 元信息
    meta:{
      title:"注册"
    }
  },
  {
    path:"/adress",
    component:adress,
    // 元信息
    meta:{
      title:"地址列表"
    }
  },

  {
    path:"/detail/:id",
    component:detail,
    // 元信息
    meta:{
      title:"详情页"
    }
  },
  {
    path:"/list",
    component:list,
    // 元信息
    meta:{
      title:"商品列表"
    }
  }
  ,
  {
    path:"/pay",
    component:pay,
    // 元信息
    meta:{
      title:"支付列表"
    }
  }
  ,
  {
    path:"/order",
    component:order,
    meta:{
      title:"确认订单",
      goBack:"true"
    }
  }
  ,
  {
    path:"/index",
    component:index,
    children:[
      {
        path:"store",
        component:store,
        // 元信息
        meta:{
          title:"商城"
        }
      },
      {
        path:"cate",
        component:cate,
        // 元信息
        meta:{
          title:"分类"
        }
      },
      {
        path:"mine",
        component:mine,
        // 元信息
        meta:{
          title:"我的"
        }
      },
      {
        path:"shop",
        component:shop,
        // 元信息
        meta:{
          title:"购物车"
        }
      },
      {
        path:"",
       redirect:store,
       // 元信息
       meta:{
         title:"商城"
       }
      },
      
      
    ]
  },
  {
    path:"*",
    redirect:"/login"
  }
  
  

]

const router = new VueRouter({
  routes:routes
})

export default router
// router第六天内容
